import { Injectable } from '@angular/core';
import {FormControl, FormGroup} from "@angular/forms";

@Injectable()
export class FormValidatorService {

  constructor() { }

  // 密码和确认密码;
  passwordValidator(group: FormGroup): any {
    const password: FormControl = group.get('password') as FormControl;
    const ensurePassword: FormControl = group.get('ensurePassword') as FormControl;
    const valid = password.value === ensurePassword.value;
    return valid ? null : { ensure: {description: '密码和确认密码不一致!'} };
  }

}
